library _;

import 'package:extended_text/extended_text.dart';
import 'package:flutter/material.dart';
import 'package:flutter_app/Const/IFinal.dart';
import 'package:flutter_app/Extension/String++.dart';
import 'package:flutter_app/Extension/special_text/my_special_text_span_builder.dart';
import 'package:flutter_app/Model/MessageModel.dart';
import 'package:flutter_app/Page/Main/Main/main.dart';
import 'package:flutter_app/Page/Message/Chat/main.dart';
import 'package:flutter_app/View/MyRefresher.dart';
import 'package:flutter_app/View/MyViews.dart';
import 'package:flutter_slidable/flutter_slidable.dart';
import 'package:flutter_yfree/YFree.dart';
import 'package:flutter_yim/YIM.dart';

part 'controller.dart';
part 'view.dart';

class MainPage_Message extends YKeepAlivePage {
  MyRefresherController? refresherController;
  List<ConversationModel>? conversations;

  @override
  void yOnCreate() {
    IFinal.Others.mainPage.controller_queryRecentConversations();
  }

  @override
  void yOnDestory() {
    refresherController?.dispose();
  }

  @override
  bool ySafeAreaBottom() => false;

  @override
  Widget yBuild(BuildContext context) {
    return Container(
      color: IFinal.Colors.pageBG,
      child: Column(
        children: [
          YAppBar(title: YIM.userManager.isLogin() ? "消息" : "连接中···", canBack: false),
          Expanded(
            child: MyRefresher(
              type: MyRefresherType.None,
              emptyTitle: "暂无消息",
              emptyImage: "images/bg_empty_message.png",
              onCreated: (controller) => refresherController = controller,
              child: ListView.builder(
                primary: false,
                shrinkWrap: true,
                padding: EdgeInsets.zero,
                itemCount: conversations?.length ?? 0,
                itemBuilder: (context, index) => view_item(index),
              ),
            ),
          ),
        ],
      ),
    );
  }
}
